<?php

namespace App\Utility;

use EasySwoole\Component\Singleton;
use EasySwoole\HttpClient\Bean\Response;
use EasySwoole\HttpClient\Exception\InvalidUrl;
use EasySwoole\HttpClient\HttpClient;

class Express
{
    use Singleton;

    /**
     * @param $host
     * @param $code
     * @param $number
     * @return mixed
     * @throws InvalidUrl
     */
    public function getExpress($host, $code, $number)
    {
        $client = new HttpClient($host);
        $client->setUrl($host);
        $client->setQuery(['number' => $number]);
        $client->setHeaders([
            "Authorization" => "APPCODE " . $code
        ]);
        $response = $client->get();
        return $response->getBody();
    }

    public function lvy($name){
        $client = new HttpClient('https://scenicspot.market.alicloudapi.com');
        $client->setUrl('https://scenicspot.market.alicloudapi.com/lianzhuo/scenicspot');
        $client->setQuery(['provice' => '甘肃']);
        $client->setQuery(['city' => '兰州']);
        $client->setQuery(['spot' => $name]);
        $client->setHeaders([
            "Authorization" => "APPCODE " . '6c1c82c3ec0a48e3a79110c79786d5a0'
        ]);
        $response = $client->get();
        return $response->getBody();
    }
}